<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">快捷入口</span>
    </div>
    <div class="control-body add-foot-bottom">
      <div class="control-section">
        <!-- 主标题 -->
        <div class="control-item">
          <div class="control-title">
            <span>主标题</span>
            <span class="reset" @click="resetItem('title')">重置</span>
          </div>
          <div class="control-content">
            <div class="input-box">
              <a-input v-model="params.title" placeholder="请输入标题文案" />
            </div>
          </div>
        </div>
        <!-- 副标题 -->
        <div class="control-item">
          <div class="control-title">
            <span>副标题</span>
            <span class="reset" @click="resetItem('subtitle')">重置</span>
          </div>
          <div class="control-content">
            <div class="input-box">
              <a-input
                v-model="params.subtitle"
                placeholder="请输入副标题文案"
              />
            </div>
          </div>
        </div>
        <!-- 主标题颜色 -->
        <colorControl
          :color.sync="params.titleColor"
          title="主标题颜色"
          @reset="resetItem('titleColor')"
          @change="setTitleColor"
        ></colorControl>
        <!-- 副标题颜色 -->
        <colorControl
          :color.sync="params.subtitleColor"
          title="副标题颜色"
          @reset="resetItem('subtitleColor')"
          @change="setSubtitleColor"
        ></colorControl>
        <!-- 图片设置 -->
        <uploadImg
          :uploadImg="params.picImg"
          size="750*264px"
          @uploadSuccess="uploadSuccess"
          @deleteImg="deleteImg"
        ></uploadImg>
        <!-- 添加连接 -->
        <div class="bg-header add-padding-bottom">
          <span>添加链接</span>
          <span class="reset" @click="resetItem('memberCardLink')">重置</span>
        </div>
        <chooseLink :link="params.link" @chooseEnd="chooseLink"></chooseLink>
      </div>
    </div>
  </div>
</template>

<script>
import colorControl from "@/components/DiyNew/diy/baseControl/colorControl/index.vue";
import uploadImg from "@/components/DiyNew/uploadImg/index.vue";
import chooseLink from "@/components/DiyNew/chooseLink/index.vue";

export default {
  name: "userMemberTabControl",
  components: {
    colorControl,
    uploadImg,
    chooseLink,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      defaultTabItem: {
        title: "标题",
        subtitle: "副标题",
        link: {},
        picImg: "",
        titleColor: "#262626",
        subtitleColor: "#B4853F",
      },
    };
  },
  watch: {},
  computed: {},
  mounted() {},
  methods: {
    setWithActionItem(e, key) {
      this.$setWithAction(this.params, key, e);
    },
    setTitleColor(e) {
      this.$set(this.params, "titleColor", e);
    },
    setSubtitleColor(e) {
      this.$set(this.params, "subtitleColor", e);
    },
    resetItem(key) {
      this.$set(this.params, key, this.defaultTabItem[key]);
    },
    uploadSuccess(e) {
      console.log(e);
      this.$set(this.params, "picImg", e.val);
    },
    deleteImg() {
      this.resetItem("picImg");
    },
    chooseLink(e) {
      this.$set(this.params, "link", e);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .reset {
            font-size: 12px;
            font-weight: 400;
            color: #8e8e8e;
            cursor: pointer;
          }
        }
        .control-content {
          .input-box {
            width: 100%;
            height: 40px;
            border-radius: 4px;
            input {
              height: 100%;
              background-color: #f6f7f9;
              border: 0 none;
            }
          }
        }
      }
      .bg-header {
        width: 100%;
        padding: 24px 0 0 0;
        font-size: 12px;
        color: #000000;
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .reset {
          font-size: 12px;
          font-weight: 400;
          color: #8e8e8e;
          cursor: pointer;
        }
      }
      .bg-header {
        width: 100%;
        padding: 24px 0 0 0;
        font-size: 12px;
        color: #000000;
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .reset {
          font-size: 12px;
          font-weight: 400;
          color: #8e8e8e;
          cursor: pointer;
        }
      }
      .add-padding-bottom {
        padding-bottom: 14px;
      }
    }
  }
  .add-foot-bottom{
      padding-bottom: 20px;
  }
}
</style>
